package br.edu.ifrn.servlets;


import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.edu.ifrn.beans.Estagio;
import br.edu.ifrn.persistencia.EstagioDAO;


@SuppressWarnings("serial")
public class EstagioServlet extends HttpServlet {
	HttpSession sessao;
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		sessao = req.getSession();
		sessao.removeAttribute("mensagem");
		addEstagio(req, resp);
		
	}
		protected void addEstagio(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
			Estagio e = new Estagio();
			e.setIdAluno(req.getParameter("idpessoa"));
			e.setComentario(req.getParameter("comentario"));
			e.setIdConvenio(req.getParameter("idconvenio"));
			
			EstagioDAO proBanco = new EstagioDAO();
			proBanco.inserirEstagio(e);
			
			sessao.setAttribute("mensagem", "estagio Criado com sucesso");
			RequestDispatcher jsp = req.getRequestDispatcher("admins.jsp");
			jsp.forward(req, resp);
		}
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
	}

}
